import axios from 'axios'
export default
function(e,giveurl,delurl,arrt,a,callback){
    var index = e.target.getAttribute('index');
    var that = a;
    a.$set(arrt,index,!arrt[index]);
    if(arrt[index]){
        axios.post(giveurl,{
            userName:that.$store.state.userName,
            userId:that.$store.state.userId,
            articleId:e.target.getAttribute('articleId')
        }).then(function(res){
           if(res.data.ok===1){
            
            callback();
           }
        })
    }else{
        axios.get(delurl,{
            params:{
                userId:that.$store.state.userId,
                articleId:e.target.getAttribute('articleId')
            }
        }).then(function(res){
            if(res.data.ok===1){
                a.articles=[];
                callback();
            }
        })
    }
}
